<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <!-- layout::Public:top::60 -->
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>TDX指数发布/修改</title>
        <script type='text/javascript' src='__PUBLIC__/JQuery/jquery-1.4.4.js'></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.ui.core.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.effects.core.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.ui.widget.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.ui.button.js"></script>
        <link rel="stylesheet" type="text/css" href="./Public/JQuery/themes/base/jquery.ui.all.css" />
        <script type="text/javascript">
            _editor_url  = "/TDX/Public/xinha/"   // (preferably absolute) URL (including trailing slash) where Xinha is installed
            _editor_lang = "cn";       // And the language we need to use in the editor.
            _editor_skin = "titan";    // If you want use a skin, add the name (of the folder) here
            _editor_icons = "classic"; // If you want to use a different iconset, add the name (of the folder, under the `iconsets` folder) here
        </script>
        <script type='text/javascript' src='__PUBLIC__/xinha/XinhaCore.js'></script>
        <script type='text/javascript' src='__PUBLIC__/xinha/Xinha_config.js'></script>
        <script type='text/javascript' src='__PUBLIC__/js/pagecontrol.js'></script>
        <script type='text/javascript' src='__PUBLIC__/js/html.js'></script>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/grid.css">
        <style type="text/css">
            ul a{
                text-decoration: none;
                color: rgb(29,32,136);
            }
            ul a:hover{
                font-weight: bold;
                color: rgb(132,132,132);
            }
            .pageNum{border: 1px solid #999;padding:2px 8px;display: inline-block;}
            .cPageNum{font-weight: bold;padding:2px 5px;}
            #pageNav a:hover{background: #fff4d8; }
            #pageNav a{text-decoration: none;color:rgb(132,132,132);font-family:'Arial'}

        </style>
        <script type="text/javascript">
            //For JQuery Functions
            gArray = [];
            page = 1;
            totalpages = 0;
            perPage = 10;
            currentEditID = -1;
            $(document).ready(function()
            {
                $("#addnew").button().click(function(){
                    var d = new Date();
                    xinha_editors.XinhaTextArea.setHTML(Date());
                    $("#Title").attr("value", d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate());
                    $("#isappend").text("\u65b0\u589e\u6a21\u5f0f");
                    currentEditID = -1;
                });
                $.post("/TDX/index.php?s=/Core/jsonTDXPages", {'per':perPage}, function(data){
                    totalpages = data.data;
                    totalpages = parseInt(totalpages);
                    pageNav.next = "\u4e0b\u4e00\u9875";
                    pageNav.pre = "\u4e0a\u4e00\u9875";
                    pageNav.go(1, totalpages);
                }, "json");
                pageNav.fn = function(p, pn)
                {
                    $.post("/TDX/index.php?s=/Core/jsonTDXList", {'page':p, 'per':perPage}, function(data){
                        gArray = data.data;
                        $("#liTemplate").show();
                        var tmp = $("#liTemplate").clone();
                        $("ul").children().remove();
                        $("ul").append(tmp);
                        for(var i=0; i<perPage; i++)
                        {
                            if(gArray.length == i)
                                break;
                            var obj = $("#liTemplate").clone();
                            obj.find("a").text(gArray[i].title);
                            obj.find("a").attr("index", i);
                            obj.find("a").click(function(){
                                $("#Title").attr("value", $(this).text());
                                var index = $(this).attr("index");
                                xinha_editors.XinhaTextArea.setHTML(htmlDecode(gArray[index].content));
                                currentEditID = gArray[index].ID;
                                $("#isappend").text("\u7f16\u8f91\u6a21\u5f0f");
                            });
                            $("ul").append(obj);
                        }
                        $("#liTemplate").hide();
                    }, "json");
                }
            $("#modify").button().click(function(){
                if($("#Title").text()=="")
                {
                    alert("标题不能为空！");
                    return;
                }
                var str = htmlEncode(xinha_editors.XinhaTextArea.getHTML());
                if(currentEditID == -1)
                {
                    //Append
                    var a = $('form').serializeArray();
                    a = a[0];   
                    $.post("/TDX/index.php?s=/Core/postTDX", {
                        'title'         :$("#Title").val(),
                        'content'       :str,
                        'hash'          :a.value
                    }, function(data){
                        var info = data.info;
                        alert(info);
                    }, "json");
                    return;
                }
            $.post("/TDX/index.php?s=/Core/modifyTDX", {
                'ID'           :currentEditID,
                'title'         :$("#Title").val(),
                'content'       :str
            }, function(data){
                var info = data.info;
                alert(info);
            }, "json")
        });
                
    });
    //For Pure JavaScript Functions
            
        </script>
    </head>
    <body>
        <!-- Contents here -->
        <div class="row">
            <div class="titlecolumn grid_3" style="text-align:left">
                <p class="smalltitle">
                    选择要编辑的指数图表
                </p>
                <ul type="circle">
                    <li id="liTemplate"><a index="" href="#">我是第一篇文章~</a></li>
                </ul>
                <div style="text-align:center">
                    <div id="pageNav" style="margin-bottom:10px"></div>
                    <input type="button" value="新增TDX指数" id="addnew" />
                </div>
            </div>
            <div class="titlecolumn grid_9" style="text-align:left">
                <p class="smalltitle">编辑区</p>
                <div id="isappend" style="border-color:rgb(132,132,132);border-width:2px;border-style:solid;font-family:'Microsoft YaHei';font-size:16px;color:rgb(29,32,136);text-align:center">新增模式</div>
                标题：<input type="text" name="Title" id="Title">
                <textarea id="XinhaTextArea" name="XinhaTextArea" rows="10" cols="50" style="width: 640px"></textarea>
                <div style="text-align:right"><input style="margin-right:40px" type="button" value="确认提交/修改" id="modify" /></div>
                <form></form>
                <div style="display:block;border-color:red;border-width:2px;background-color:lightsteelblue;text-align:center">请注意，页面的宽度不要大于600px(即编辑器宽度)，否则在TDX指数页上会显示错误~<br/>但是图片会自动调整，所以图片的宽度可以不用动~<br/>P.S:表格宽度最好按照百分比来设定（默认即是)，这样在哪儿都显示正确</div>
            </div>
        </div>

    </body>
    <!-- layout::Public:bottom::60 -->
</html>